package com.mmdccj.yugu.service.impl;

import com.mmdccj.yugu.entity.SocialInfo;
import com.mmdccj.yugu.mapper.SocialInfoMapper;
import com.mmdccj.yugu.service.SocialInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @Author: MMDCCJ
 * @date: 2023-11-30 20:30
 */
@Service
public class SocialInfoServiceImpl implements SocialInfoService {
    //自动注入SocialInfoMapper实例
    @Autowired
    SocialInfoMapper socialInfoMapper;

    /**
     * 根据用户ID获取社交信息
     *
     * @param id 用户ID
     * @return SocialInfo 包含关注数、粉丝数和动态数的社交信息
     */
    @Override
    public SocialInfo getSocialInfoByUserId(String id) {
        SocialInfo info = new SocialInfo();
        info.setConcerns(socialInfoMapper.getNumberOfConcernsById(id));
        info.setFans(socialInfoMapper.getNumberOfFansById(id));
        info.setPost(socialInfoMapper.getNumberOfPost(id));
        return info;
    }
}
